{extend name="admin/b2c/base" /}
{block name="resources"/}
<style>
.mytable {border: 0;}
.style0list tbody td {vertical-align: middle;}
.style0list  tbody tr {border-bottom: 1px dashed  #E3E3E3;}
a{
	cursor:pointer;
}
</style>
{/block}
{block name="main"}
<div class="mod-table">
	<div class="mod-table-head">
		<table class="mytable">
			<tr>
				<th width="10%">
					<input type="text" id='search_text' placeholder="请输入会员名称" />
					<input type="button" onclick="searchData()" value="搜索" />
				</th>
			</tr>
		</table>
		<div class="style0list">
			<table>
				<thead>
					<tr align="center">
						<th><label style="margin-left: 5px;"><input type="checkbox" onclick="CheckAll(this)"></label></th>
						<th>会员头像</th>
						<th>用户名</th>
						<th>用户手机号</th>
						<th>昵称</th>
						<th>积分</th>
						<th>状态</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody></tbody>
			</table>
		</div>
	</div>
</div>
{/block}
{block name="script"}
{include file="admin/b2c/openDialog" /}
{include file="admin/b2c/pageCommon"/}
<script type="text/javascript">
	function LoadingInfo(pageIndex) {
		var search_text = $("#search_text").val();
		$.ajax({
			type : "post",
			url : "ADMIN_MAIN/Member/memberList",
			async : true,
			data : {
				"pageIndex" : pageIndex, "search_text" : search_text
			},
			success : function(data) {
				$("#page_count").val(data["page_count"]);
				$("#pageNumber a").remove();
				var html = '';
				if (data["data"].length > 0) {
					for (var i = 0; i < data["data"].length; i++) {
						html += '<tr align="center">';
						html += '<td><div class="cell"><label ><input name="sub" type="checkbox" value="'+ data["data"][i]["uid"]+'" ></label></div></td>';
						//html += '<td>' + data["data"][i]["uid"]+ '</td>';
						html += '<td>';
						if(data["data"][i]["user_headimg"] ==""){
							html += '<img src="__STATIC__/images/default_user_portrait.gif" class="head-portrait" />';							
						}else{
							html += '<img src="__UPLOAD__/'+data["data"][i]["user_headimg"]+'" class="head-portrait" />';
						}
						html += '</td>';
						if (data["data"][i]["user_name"] == null || "" == data["data"][i]["user_name"]) {
							html += '<td>--</td>';
						} else {
							html += '<td>' + data["data"][i]["user_name"] + '</td>';
						}
						if (data["data"][i]["user_tel"] == null || "" == data["data"][i]["user_tel"]) {
							html += '<td>--';
						} else {
							html += '<td>' + data["data"][i]["user_tel"];
						}
						html += '<td>' + data["data"][i]["nick_name"] + '</td>';
						html += '<td>' + data["data"][i]["point"] + '</td>';	
						
						html += data["data"][i]["user_status"] == 0 ? '<td style="color:red;">锁定</td>' : '<td style="color:green;">正常</td>';
						if(data["data"][i]["is_system"] != 1){
							if(data["data"][i]["user_status"] == 0){
								html += '<td><a onclick="unlockuser('+ data["data"][i]["uid"]+')">解锁</a></td>';
							}else{
								html += '<td><a onclick="lockuser('+ data["data"][i]["uid"]+')">锁定</a></td>';
							}
						}else{
							html += '<td>-</td>';
						}
						html += '</tr>';
					}
				} else {
					html += '<tr align="center"><th colspan="9">暂无符合条件的数据记录</th></tr>';
				}
				$(".style0list tbody").html(html);
					var totalpage = $("#page_count").val();
				if (totalpage == 1) {
					changeClass("all");
				}
				var $html = pagenumShow(jumpNumber,totalpage,{$pageshow})
				$("#pageNumber").append($html);
			}
		});
	}
	//全选
	function CheckAll(event){
		var checked = event.checked;
		$(".style0list tbody input[type = 'checkbox']").prop("checked",checked);
	}

	function searchData(){
		LoadingInfo(1);
	}
	//锁定会员
	function lockuser(uid)
	{
		$.ajax({
			type : "post",
			url : "ADMIN_MAIN/Member/memberLock",
			async : true,
			data : {
				"id" : uid
			},
			success : function(data) {
				if (data["code"] > 0) {
					showMessage('success', data["message"],'ADMIN_MAIN/Member/memberList');
				}else{
					showMessage('error', data["message"]);
				}
			}
		});
	}
	//解锁会员
	function unlockuser(uid)
	{
		$.ajax({
			type : "post",
			url : "ADMIN_MAIN/Member/memberUnlock",
			async : true,
			data : {
				"id" : uid
			},
			success : function(data) {
				if (data["code"] > 0) {
					showMessage('success', data["message"],'ADMIN_MAIN/Member/memberList');
				}else{
					showMessage('error', data["message"]);
				}
			}
		});
	}
</script>
{/block}